package com.learning.demos;

public class TestTransferValue {

    static class Person{
        String name;
        int age;

        public Person(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }


    public void changeValue1(int age) {
        age = 30;
    }

    public void changeValue2(Person person) {
        person.setName("xxx");
    }

    public void changeValue3(String string) {
        string = "xxx";
    }

    public static void main(String[] args) {
        TestTransferValue testTransferValue = new TestTransferValue();
        int age = 20;
        testTransferValue.changeValue1(age);
        System.out.println("age=======" + age);

        Person person = new Person("abc");
        testTransferValue.changeValue2(person);
        System.out.println("PersonName======" + person.getName());

        String str = "abc";
        testTransferValue.changeValue3(str);
        System.out.println("String========" + str);
    }
}
